"""
@name : 数字类型
@author : wenyao
@projectname: xsfh
"""
#整型  python2中有长整型和整型， python3只有整型
#整型的表示 -- int
#二进制  以0b开头  bin
#八进制  以0o开头  oct
#十六进制 以0x开头  hex

# >>> a = 123
# >>> type(a)
# <class 'int'>
# >>> b = 0b111
# >>> type(b)
# <class 'int'>
# >>>

# >>> a = 123
# >>> type(a)
# <class 'int'>
# >>> b = 0b111
# >>> type(b)
# <class 'int'>
# >>> bin(a)
# '0b1111011'
# >>> result = bin(a)
# >>> type(result)
# <class 'str'>
# >>> bin(0o77)
# '0b111111'
# >>> bin("0o77")
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# TypeError: 'str' object cannot be interpreted as an integer
# >>> oct(15)
# '0o17'
# >>> hex(15)
# '0xf'
# >>> int(0b1111)
# 15
# >>> int('0b1111')
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# ValueError: invalid literal for int() with base 10: '0b1111'
# >>> int('1111')
# 1111
# >>> int('0b1111')
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# ValueError: invalid literal for int() with base 10: '0b1111'
# >>> int('0b1111',base=2)
# 15

# num1 = int(input("请输入数字一:"))
# num2 = int(input("请输入数字二:"))
# print("两数之和为:",num1+num2)

# num1 = int(input("请输入数字:"))
# print("对应二进制为：",bin(num1))
# print("对应八进制为:",oct(num1))
# print("对应十六进制为:",hex(num1))


#浮点数  -- float   - 不精确的，使用二进制来表示
#带小数点的
# >>> a = 1.333
# >>> type(a)
# <class 'float'>
# >>> i = 1
# >>> i = i-0.1
# >>> i
# 0.9
# >>> i = i -0.1
# >>> i
# 0.8
# >>> i = i - 0.1
# >>> i
# 0.7000000000000001

#deciaml 精确的小数
# >>> from decimal import Decimal
# >>> mydec = Decimal(12.222)
# >>> mydec
# Decimal('12.2219999999999995310417943983338773250579833984375')
# >>> mydec = Decimal('12.222')
# >>> mydec
# Decimal('12.222')
# >>> type(mydec)
# <class 'decimal.Decimal'>


#复数  实部和虚部都存的浮点数
# >>> a = 4+5j
# >>> type(a)
# <class 'complex'>
# >>> dir(a)
# ['__abs__', '__add__', '__bool__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__int__', '__le__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__pos__', '__pow__', '__radd__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rmod__', '__rmul__', '__rpow__', '__rsub__', '__rtruediv__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', 'conjugate','imag', 'real']
# >>> a.real
# 4.0
# >>> a.imag
# 5.0
